<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:p="http://primefaces.org/ui"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core">

    <p:dialog header="Adauga/Editeaza utilizator" widgetVar="add_user_WV" dynamic="true" minHeight="300" width="600"
              modal="true">

        <h:form id="create_user_form">
            <p:watermark value="Tapaţi pentru a selecta dosarul" for="folders"/>

            <h:panelGrid columns="2" columnClasses="column-1, column-200" styleClass="form-elements">
                <p:outputLabel for="user_email" value="Adresa de e-mail:"/>
                <p:inputText id="user_email" value="#{userAdministrationBean.selectedUser.email}"
                             required="true" requiredMessage="Adresa de e-mail necesara."
                             disabled="#{userAdministrationBean.editUserDisabled()}"/>

                <p:outputLabel for="folders" value="Dosar:"/>
                <p:autoComplete id="folders" dropdown="true" value="#{userAdministrationBean.selectedUser.folder}"
                                completeMethod="#{userAdministrationBean.complete}"
                                disabled="#{userAdministrationBean.editUserDisabled()}"
                                var="f" itemLabel="#{f.firstName} #{f.lastName}" itemValue="#{f}"
                                converter="#{objectMappingConverter}"
                                minQueryLength="3" maxlength="20" required="true"
                                requiredMessage="Dosarul este necesar.">
                </p:autoComplete>

                <p:outputLabel for="groups" value="Grupa:"/>
                <p:selectOneMenu id="groups" value="#{userAdministrationBean.selectedUser.userGroup}"
                                 converter="#{objectMappingConverter}" required="true" requiredMessage="Grup necesar">
                    <f:selectItem itemLabel="Selecteaza..."/>
                    <f:selectItems value="#{userAdministrationBean.groups}" var="g" itemLabel="#{g.name}"
                                   itemValue="#{g}"/>
                </p:selectOneMenu>

                <p:outputLabel for="user-enabled" value="Activ:"/>
                <p:selectBooleanCheckbox id="user-enabled" value="#{userAdministrationBean.selectedUser.enabled}"/>

            </h:panelGrid>

            <p:outputPanel layout="block" style="width: 90%;margin: 5px auto" rendered="#{userAdministrationBean.selectedUser.id == 0}">
                <h:outputText value="După salvare, utilizatorul creat va fi notificat pe adresa electronica specificata mai sus, despre crearea contului si parola generata." />
            </p:outputPanel>
            <p:outputPanel layout="block" style="border-top: 1px solid #A8A8A8; padding: 5px;">
                <p:commandButton icon="ui-icon-disk" value="Salveaza" update="@form :users_content:users_list_form"
                                 actionListener="#{userAdministrationBean.saveUser}"
                                 oncomplete="if (args &amp;&amp; !args.validationFailed) add_user_WV.hide()"/>
                <p:commandButton value="Renunta" onclick="PF('add_user_WV').hide();" process="@none"/>
            </p:outputPanel>
        </h:form>
    </p:dialog>


</ui:composition>
